package cn.flashk.controls.skin {
	import cn.flashk.controls.ProgressBar;
	import cn.flashk.controls.support.UIComponent;
	
	import com.skins.Skin;
	
	import flash.display.DisplayObject;
	
	public class ProgressBarSkinL extends ActionDrawSkin {
		private var tar:UIComponent;
		private var shape:DisplayObject;
		private var shapeBar:DisplayObject;
		private var progressBar:ProgressBar;
		
		/**
		 * 自定义皮肤进度条 
		 * @param skinID
		 * 
		 */		
		public function ProgressBarSkinL(skinID:String){
			shape = Skin.librarys.getSkin(skinID, "barBg")
			shapeBar = Skin.librarys.getSkin(skinID, "bar");
		}
		
		override public function init(target:UIComponent, styleSet:Object):void {
			tar = target as UIComponent;
			progressBar = target as ProgressBar;
			
			shape.width= tar.compoWidth;
			shape.height= tar.compoHeight;
			target.addChildAt(shape, 0);
			
			shapeBar.width = 1;
			shapeBar.height= tar.compoHeight;
			target.addChild(shapeBar);
		}
		
		override public function reDraw():void {
			var width:Number = tar.compoWidth - 0;
			var height:Number = tar.compoHeight - 0;
			shape.width = width;
			shape.height= height;
			
			shapeBar.height= height;
		}
		
		public function updateValue():void {
			var barWidth:int = tar.compoWidth * progressBar.value / progressBar.maximum;
			if (progressBar.value > 0&&barWidth>0){
				shapeBar.cacheAsBitmap = true;
				shapeBar.width = barWidth;
			}
		}
	}
}